﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataStructs
{
    class DoubleLinkList
    {

        private DNode  headNode;

        // add node to double link list
        public void addNode(Object n)
        {
            DNode temp = headNode;
            DNode newNode = new DNode(n);

            if (headNode == null) // empty list
            {
                
                headNode = newNode;

            }
            else
            {
                // the node is not empty
                newNode.Flink = temp;
                newNode.BLink = null;
                temp.BLink = newNode;
                headNode = newNode;

            }

        }

        public void PrintDList()
        {
            if (headNode == null)
            {

                Console.Write("Empty List");


            }
            else
            {
                DNode currentNode = headNode;

                while ((currentNode != null))
                {
                    Console.Write(currentNode.data + "----->" );
                    currentNode = currentNode.Flink;
                    

                }

                

            }

        }

    }
}
